#!ipxe

goto ${menu} ||

:live_menu
set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch amd64 ||
iseq ${os_arch} i386 && set os_arch i686 ||
set os Clonezilla
menu ${os}
item --gap ${os} Versions
item debian ${space} ${os} Debian Based
iseq ${os_arch} amd64 && item ubuntu ${space} ${os} Ubuntu Based ||
choose live_version || goto live_exit
menu ${os} ${live_version} - ${os_arch}
item --gap ${os} Flavors
goto ${live_version}

:debian
{% for key, value in endpoints.items() %}
{% if value.os == "clonezilla" and "debian" in key %}
iseq ${os_arch} {{ value.arch }} && item {{ value.path }} ${space} {{ value.os | title }} {{ value.version | title }} {{ value.flavor | title }} ||
{% endif %}
{% endfor %}
choose path || goto live_menu
goto clonezilla-boot

:ubuntu
{% for key, value in endpoints.items() %}
{% if value.os == "clonezilla" and "ubuntu" in key %}
iseq ${os_arch} {{ value.arch }} && item {{ value.path }} ${space} {{ value.os | title }} {{ value.version | title }} {{ value.flavor | title }} ||
{% endif %}
{% endfor %}
choose path || goto live_menu
goto clonezilla-boot

:clonezilla-boot
imgfree
set url ${live_endpoint}${path}
kernel ${url}vmlinuz boot=live username=user union=overlay config components noswap edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=${url}filesystem.squashfs {{ kernel_params }}
initrd ${url}initrd
boot

:live_exit
clear menu
exit 0

